package com.bmf.admin.module.attribute.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bmf.admin.module.attribute.entity.Attribute;
import com.bmf.admin.module.attribute.mapper.AttributeMapper;
import com.bmf.admin.module.attribute.service.AttributeService;
import com.bmf.core.result.PageResponse;

import org.springframework.stereotype.Service;


/**
 * (Attribute)表服务实现类
 *
 * @author makejava
 * @since 2022-11-04 17:32:53
 */
@Service("attributeService")
public class AttributeServiceImpl extends ServiceImpl<AttributeMapper, Attribute> implements AttributeService {

    @Override
    public PageResponse<Attribute> selectPage(Attribute attribute) {
        LambdaQueryWrapper<Attribute> wrapper = new LambdaQueryWrapper();
        if("".equals(attribute.getCname())){
            return null;
        }
        if(StrUtil.isNotBlank(attribute.getCname())){
            wrapper.like(Attribute::getCname, attribute.getCname());
        }
        Page<Attribute> page = new Page(attribute.getPageNo(),attribute.getPageSize());
        page(page,wrapper);
        return new PageResponse<>(page.getRecords(),page.getTotal(),attribute.getPageNo(),attribute.getPageSize());
    }
}
